import com.rongyi.transfer.service.TransferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.sql.*;

@Component
@RestController
@RequestMapping("/transfer")
public class TransferController {
    @Autowired
    private TransferService transferService;

	// 迁移
    @GetMapping("/moveTable/{shortName}")
    public String moveTable(@PathVariable("shortName") String shortName) throws SQLException {
    	// c01、c02表需要额外处理
        if (shortName.equals("c01") || shortName.equals("c02")) {
            transferService.moveCustom(shortName);
        // 其他表照常处理
        } else {
            transferService.moveData(shortName);
        }
        return shortName + "迁移完成";
    }
}
